package com.anxin.act.config.web;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anxin.framework.aspectj.lang.annotation.Log;
import com.anxin.framework.aspectj.lang.enums.BusinessType;
import com.anxin.act.config.entity.WfApplyFormField;
import com.anxin.act.config.service.WfApplyFormFieldService;
import com.anxin.framework.web.controller.BaseController;
import com.anxin.framework.web.entity.AjaxResult;
import com.anxin.common.utils.poi.ExcelUtil;
import com.anxin.framework.web.page.TableDataInfo;

/**
 * 流程申请单字段Controller
 *
 * @author jbs
 * @date 2020-03-13
 */
@RestController
@RequestMapping("/field/wfApplyFormField")
public class WfApplyFormFieldController extends BaseController{
    @Autowired
    private WfApplyFormFieldService wfApplyFormFieldService;

    /**
     * 查询流程申请单字段列表
     */
    @PreAuthorize("@ss.hasPermi('act:config:view')")
    @GetMapping("/list")
    @Log(title = "查询流程申请单字段列表", businessType = BusinessType.LIST)
    public TableDataInfo list(WfApplyFormField wfApplyFormField){
        startPage();
        List<WfApplyFormField> list = wfApplyFormFieldService.findList(wfApplyFormField);
        return getDataTable(list);
    }

    /**
     * 导出流程申请单字段列表
     */
    @PreAuthorize("@ss.hasPermi('act:config:export')")
    @Log(title = "流程申请单字段", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WfApplyFormField wfApplyFormField) {
        List<WfApplyFormField> list = wfApplyFormFieldService.findList(wfApplyFormField);
        ExcelUtil<WfApplyFormField> util = new ExcelUtil<WfApplyFormField>(WfApplyFormField.class);
        return util.exportExcel(list, "field");
    }

    /**
     * 获取流程申请单字段详细信息
     */
    @PreAuthorize("@ss.hasPermi('act:config:view')")
    @GetMapping(value = "/{id}")
    @Log(title = "获取流程申请单字段详细信息", businessType = BusinessType.LIST)
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return AjaxResult.success(wfApplyFormFieldService.getById(id));
    }

    /**
     * 保存流程申请单字段
     */
    @PreAuthorize("@ss.hasPermi('act:config:edit')")
    @Log(title = "流程申请单字段", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody WfApplyFormField wfApplyFormField){
        return toAjax(wfApplyFormFieldService.save(wfApplyFormField));
    }


    /**
     * 删除流程申请单字段
     */
    @PreAuthorize("@ss.hasPermi('act:config:remove')")
    @Log(title = "流程申请单字段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable(("id")) Long id){
        return toAjax(wfApplyFormFieldService.deleteById(id));
    }
}
